<?
//print_r($categoria);
?>


 <script type="text/javascript" charset="utf-8">
 $(function(){
 	$("select#figlio_di").change(function(){
 		$.getJSON("/aj_select.php?req=ordcat&id_negozio=<?echo $this->negozio->id;?>&",{id_padre: $(this).val()}, function(j){
 			var options = '';
 			for (var i = 0; i < j.length; i++) {
 				options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
 			}
 			$("#ordine").html(options);
 			$('#ordine option:first').attr('selected', 'selected');
 		})
 	})
 })
</script>



<div id="content"> 
    <h1 class="pagetitle"><? if($_REQUEST[mod]=="new") echo "Inserisci"; else echo "Modifica";?> Cartella</h1>
    <a href="<? if($_REQUEST[mod]=="new") echo "/admin/"; else echo "/admin/categoria.php?id_categoria=$categoria->id" ?>" id="rss-posts">Indietro</a> 
        <div class="post"> 
     
	<h2 class="title"><? if($_REQUEST[mod]!="new") { echo $categoria->nome_ita;}else{ echo "Nuova cartella"; }?></h2>
	<p class="byline">
	<? 
	if($_REQUEST[mod]!="new") 
	{
	?>	<small>
		<p>Descrizione: <? echo $categoria->descrizione;?></p>
		<p>Percorso: <a target="negozio" href="<? echo $this->negozio->cat_struct[categorie][$categoria->id][percorso]?>"><? echo $this->negozio->cat_struct[categorie][$categoria->id][percorso]?></a> 
		<a target="negozio" href="<? echo $this->negozio->cat_struct[categorie][$categoria->id][percorso]?>"><img align="absmiddle" src="/_admin/img/viewmag.png" border="0" /></a>
		</p></small>
	<?
	}
	?>
	</p>
        
      <form id="form" action="" method="GET">
	<div class="meta"></div>

 	<div class="entry_sx"> 
        Nome </div>
        <div class="entry_dx">
          <input name="nome_ita" type="text" value="<? echo $categoria->nome_ita;?>" size="50" />
          ITA<br/>
          <input name="nome_eng" type="text" value="<? echo $categoria->nome_eng;?>" size="50" />
        ENG	</div>
      <div class="meta"></div>

 	

 	<div class="entry_sx"> 
        Descrizione </div>
        <div class="entry_dx">
          <textarea name="descrizione_ita" cols="48" rows="3"><? echo $categoria->descrizione_ita;?></textarea>
          ITA<br/>
          <textarea name="descrizione_eng" cols="48" rows="3"><? echo $categoria->descrizione_eng;?></textarea>
        ENG	</div>
      <div class="meta"></div>

 	<div class="entry_sx"> 
        Nome cartella </div>
        <div class="entry_dx">  <input name="dir_ita" type="text" id="dir_ita" value="<? echo $categoria->dir_ita;?>" size="50" /> 
        ITA<br/>
		 <input name="dir_eng" type="text" id="dir_eng" value="<? echo $categoria->dir_eng;?>" size="50" />
		 ENG
        </div>
        <div class="meta"></div>

 	<div class="entry_sx"> 
        Sottocartella di </div>
        <div class="entry_dx">
          <select name="figlio_di" id="figlio_di">
		<option value="0">|- Principale /</option>
		<?
		foreach($this->negozio->cat_struct[categorie] as $id_cat=>$tmp_cat)
		{
			$indent = ""; for($i=0;$i<=$tmp_cat[liv];$i++)$indent .= "&nbsp;&nbsp;&nbsp;"; $indent.="|-";
			$sel = ""; if($categoria->figlio_di==$id_cat) $sel = "selected";
			if($id_cat!=$categoria->id) echo "<option value=\"$id_cat\" $sel >$indent $tmp_cat[nome] $tmp_cat[percorso]/</option>";
		}
		?>
          </select>
        </div>
      <div class="meta"></div>

     
 	<div class="entry_sx"> 
        Ordine </div>
        <div class="entry_dx">
       
          <select name="ordine" id="ordine">
         
		<option value="0">Inizio</option>
		<?
		foreach($this->negozio->cat_struct[categorie] as $id_cat=>$tmp_cat){
			if($tmp_cat[figlio_di]==$categoria->figlio_di)
			{
				$sel = ""; if($tmp_cat[ordine]==($categoria->ordine-2)){$sel = "selected"; }
				if($id_cat!=$categoria->id) echo "<option $sel value=\"".($tmp_cat[ordine]+1)."\" $sel >Dopo $tmp_cat[nome]</option>";
			}
		}

		?>
          </select> 
        </div>
      <div class="meta">
	<input name="mod" value="save" type="hidden" />
	<input name="id_categoria" value="<? echo $categoria->id; ?>" type="hidden" />
	<input type="reset" name="Annulla" value="Annulla" class="pulsanti"/> <input type="submit" name="Salva" value="Salva" class="pulsanti"/></div>

 	

	</form>
    </div>


  </div>